//! \file
/*
**  Copyright (C) - Triton
**
**  This program is under the terms of the Apache License 2.0.
*/

#if defined(__unix__) || defined(__APPLE__)

#include <triton/pythonBindings.hpp>
#include <triton/pythonUtils.hpp>
#include <triton/pythonXFunctions.hpp>
#include <triton/architecture.hpp>
#include <triton/unix.hpp>



/*! \page py_SYSCALL_page SYSCALL
    \brief [**python api**] All information about the SYSCALL Python namespace.

\tableofcontents

\section SYSCALL_py_description Description
<hr>

According to the CPU architecture, the SYSCALL namespace contains all syscall numbers. The list of syscalls depends
of your kernel version. That's why the list is generated at compile time by the [extract_syscall.py](https://github.com/JonathanSalwan/Triton/blob/master/src/scripts/extract_syscall.py) script.

\section SYSCALL_py_api Python API - Items of the SYSCALL namespace
<hr>

Dependnig on your kernel version, this list is not exhaustive.

- **SYSCALL.READ**
- **SYSCALL.WRITE**
- **SYSCALL.OPEN**
- **SYSCALL.CLOSE**
- **SYSCALL.STAT**
- **SYSCALL.FSTAT**
- **SYSCALL.LSTAT**
- **SYSCALL.POLL**
- **SYSCALL.LSEEK**
- **SYSCALL.MMAP**
- **SYSCALL.MPROTECT**
- **SYSCALL.MUNMAP**
- **SYSCALL.BRK**
- **SYSCALL.RT_SIGACTION**
- **SYSCALL.RT_SIGPROCMASK**
- **SYSCALL.RT_SIGRETURN**
- **SYSCALL.IOCTL**
- **SYSCALL.PREAD64**
- **SYSCALL.PWRITE64**
- **SYSCALL.READV**
- **SYSCALL.WRITEV**
- **SYSCALL.ACCESS**
- **SYSCALL.PIPE**
- **SYSCALL.SELECT**
- **SYSCALL.SCHED_YIELD**
- **SYSCALL.MREMAP**
- **SYSCALL.MSYNC**
- **SYSCALL.MINCORE**
- **SYSCALL.MADVISE**
- **SYSCALL.SHMGET**
- **SYSCALL.SHMAT**
- **SYSCALL.SHMCTL**
- **SYSCALL.DUP**
- **SYSCALL.DUP2**
- **SYSCALL.PAUSE**
- **SYSCALL.NANOSLEEP**
- **SYSCALL.GETITIMER**
- **SYSCALL.ALARM**
- **SYSCALL.SETITIMER**
- **SYSCALL.GETPID**
- **SYSCALL.SENDFILE**
- **SYSCALL.SOCKET**
- **SYSCALL.CONNECT**
- **SYSCALL.ACCEPT**
- **SYSCALL.SENDTO**
- **SYSCALL.RECVFROM**
- **SYSCALL.SENDMSG**
- **SYSCALL.RECVMSG**
- **SYSCALL.SHUTDOWN**
- **SYSCALL.BIND**
- **SYSCALL.LISTEN**
- **SYSCALL.GETSOCKNAME**
- **SYSCALL.GETPEERNAME**
- **SYSCALL.SOCKETPAIR**
- **SYSCALL.SETSOCKOPT**
- **SYSCALL.GETSOCKOPT**
- **SYSCALL.CLONE**
- **SYSCALL.FORK**
- **SYSCALL.VFORK**
- **SYSCALL.EXECVE**
- **SYSCALL.EXIT**
- **SYSCALL.WAIT4**
- **SYSCALL.KILL**
- **SYSCALL.UNAME**
- **SYSCALL.SEMGET**
- **SYSCALL.SEMOP**
- **SYSCALL.SEMCTL**
- **SYSCALL.SHMDT**
- **SYSCALL.MSGGET**
- **SYSCALL.MSGSND**
- **SYSCALL.MSGRCV**
- **SYSCALL.MSGCTL**
- **SYSCALL.FCNTL**
- **SYSCALL.FLOCK**
- **SYSCALL.FSYNC**
- **SYSCALL.FDATASYNC**
- **SYSCALL.TRUNCATE**
- **SYSCALL.FTRUNCATE**
- **SYSCALL.GETDENTS**
- **SYSCALL.GETCWD**
- **SYSCALL.CHDIR**
- **SYSCALL.FCHDIR**
- **SYSCALL.RENAME**
- **SYSCALL.MKDIR**
- **SYSCALL.RMDIR**
- **SYSCALL.CREAT**
- **SYSCALL.LINK**
- **SYSCALL.UNLINK**
- **SYSCALL.SYMLINK**
- **SYSCALL.READLINK**
- **SYSCALL.CHMOD**
- **SYSCALL.FCHMOD**
- **SYSCALL.CHOWN**
- **SYSCALL.FCHOWN**
- **SYSCALL.LCHOWN**
- **SYSCALL.UMASK**
- **SYSCALL.GETTIMEOFDAY**
- **SYSCALL.GETRLIMIT**
- **SYSCALL.GETRUSAGE**
- **SYSCALL.SYSINFO**
- **SYSCALL.TIMES**
- **SYSCALL.PTRACE**
- **SYSCALL.GETUID**
- **SYSCALL.SYSLOG**
- **SYSCALL.GETGID**
- **SYSCALL.SETUID**
- **SYSCALL.SETGID**
- **SYSCALL.GETEUID**
- **SYSCALL.GETEGID**
- **SYSCALL.SETPGID**
- **SYSCALL.GETPPID**
- **SYSCALL.GETPGRP**
- **SYSCALL.SETSID**
- **SYSCALL.SETREUID**
- **SYSCALL.SETREGID**
- **SYSCALL.GETGROUPS**
- **SYSCALL.SETGROUPS**
- **SYSCALL.SETRESUID**
- **SYSCALL.GETRESUID**
- **SYSCALL.SETRESGID**
- **SYSCALL.GETRESGID**
- **SYSCALL.GETPGID**
- **SYSCALL.SETFSUID**
- **SYSCALL.SETFSGID**
- **SYSCALL.GETSID**
- **SYSCALL.CAPGET**
- **SYSCALL.CAPSET**
- **SYSCALL.RT_SIGPENDING**
- **SYSCALL.RT_SIGTIMEDWAIT**
- **SYSCALL.RT_SIGQUEUEINFO**
- **SYSCALL.RT_SIGSUSPEND**
- **SYSCALL.SIGALTSTACK**
- **SYSCALL.UTIME**
- **SYSCALL.MKNOD**
- **SYSCALL.USELIB**
- **SYSCALL.PERSONALITY**
- **SYSCALL.USTAT**
- **SYSCALL.STATFS**
- **SYSCALL.FSTATFS**
- **SYSCALL.SYSFS**
- **SYSCALL.GETPRIORITY**
- **SYSCALL.SETPRIORITY**
- **SYSCALL.SCHED_SETPARAM**
- **SYSCALL.SCHED_GETPARAM**
- **SYSCALL.SCHED_SETSCHEDULER**
- **SYSCALL.SCHED_GETSCHEDULER**
- **SYSCALL.SCHED_GET_PRIORITY_MAX**
- **SYSCALL.SCHED_GET_PRIORITY_MIN**
- **SYSCALL.SCHED_RR_GET_INTERVAL**
- **SYSCALL.MLOCK**
- **SYSCALL.MUNLOCK**
- **SYSCALL.MLOCKALL**
- **SYSCALL.MUNLOCKALL**
- **SYSCALL.VHANGUP**
- **SYSCALL.MODIFY_LDT**
- **SYSCALL.PIVOT_ROOT**
- **SYSCALL._SYSCTL**
- **SYSCALL.PRCTL**
- **SYSCALL.ARCH_PRCTL**
- **SYSCALL.ADJTIMEX**
- **SYSCALL.SETRLIMIT**
- **SYSCALL.CHROOT**
- **SYSCALL.SYNC**
- **SYSCALL.ACCT**
- **SYSCALL.SETTIMEOFDAY**
- **SYSCALL.MOUNT**
- **SYSCALL.UMOUNT2**
- **SYSCALL.SWAPON**
- **SYSCALL.SWAPOFF**
- **SYSCALL.REBOOT**
- **SYSCALL.SETHOSTNAME**
- **SYSCALL.SETDOMAINNAME**
- **SYSCALL.IOPL**
- **SYSCALL.IOPERM**
- **SYSCALL.CREATE_MODULE**
- **SYSCALL.INIT_MODULE**
- **SYSCALL.DELETE_MODULE**
- **SYSCALL.GET_KERNEL_SYMS**
- **SYSCALL.QUERY_MODULE**
- **SYSCALL.QUOTACTL**
- **SYSCALL.NFSSERVCTL**
- **SYSCALL.GETPMSG**
- **SYSCALL.PUTPMSG**
- **SYSCALL.AFS_SYSCALL**
- **SYSCALL.TUXCALL**
- **SYSCALL.SECURITY**
- **SYSCALL.GETTID**
- **SYSCALL.READAHEAD**
- **SYSCALL.SETXATTR**
- **SYSCALL.LSETXATTR**
- **SYSCALL.FSETXATTR**
- **SYSCALL.GETXATTR**
- **SYSCALL.LGETXATTR**
- **SYSCALL.FGETXATTR**
- **SYSCALL.LISTXATTR**
- **SYSCALL.LLISTXATTR**
- **SYSCALL.FLISTXATTR**
- **SYSCALL.REMOVEXATTR**
- **SYSCALL.LREMOVEXATTR**
- **SYSCALL.FREMOVEXATTR**
- **SYSCALL.TKILL**
- **SYSCALL.TIME**
- **SYSCALL.FUTEX**
- **SYSCALL.SCHED_SETAFFINITY**
- **SYSCALL.SCHED_GETAFFINITY**
- **SYSCALL.SET_THREAD_AREA**
- **SYSCALL.IO_SETUP**
- **SYSCALL.IO_DESTROY**
- **SYSCALL.IO_GETEVENTS**
- **SYSCALL.IO_SUBMIT**
- **SYSCALL.IO_CANCEL**
- **SYSCALL.GET_THREAD_AREA**
- **SYSCALL.LOOKUP_DCOOKIE**
- **SYSCALL.EPOLL_CREATE**
- **SYSCALL.EPOLL_CTL_OLD**
- **SYSCALL.EPOLL_WAIT_OLD**
- **SYSCALL.REMAP_FILE_PAGES**
- **SYSCALL.GETDENTS64**
- **SYSCALL.SET_TID_ADDRESS**
- **SYSCALL.RESTART_SYSCALL**
- **SYSCALL.SEMTIMEDOP**
- **SYSCALL.FADVISE64**
- **SYSCALL.TIMER_CREATE**
- **SYSCALL.TIMER_SETTIME**
- **SYSCALL.TIMER_GETTIME**
- **SYSCALL.TIMER_GETOVERRUN**
- **SYSCALL.TIMER_DELETE**
- **SYSCALL.CLOCK_SETTIME**
- **SYSCALL.CLOCK_GETTIME**
- **SYSCALL.CLOCK_GETRES**
- **SYSCALL.CLOCK_NANOSLEEP**
- **SYSCALL.EXIT_GROUP**
- **SYSCALL.EPOLL_WAIT**
- **SYSCALL.EPOLL_CTL**
- **SYSCALL.TGKILL**
- **SYSCALL.UTIMES**
- **SYSCALL.VSERVER**
- **SYSCALL.MBIND**
- **SYSCALL.SET_MEMPOLICY**
- **SYSCALL.GET_MEMPOLICY**
- **SYSCALL.MQ_OPEN**
- **SYSCALL.MQ_UNLINK**
- **SYSCALL.MQ_TIMEDSEND**
- **SYSCALL.MQ_TIMEDRECEIVE**
- **SYSCALL.MQ_NOTIFY**
- **SYSCALL.MQ_GETSETATTR**
- **SYSCALL.KEXEC_LOAD**
- **SYSCALL.WAITID**
- **SYSCALL.ADD_KEY**
- **SYSCALL.REQUEST_KEY**
- **SYSCALL.KEYCTL**
- **SYSCALL.IOPRIO_SET**
- **SYSCALL.IOPRIO_GET**
- **SYSCALL.INOTIFY_INIT**
- **SYSCALL.INOTIFY_ADD_WATCH**
- **SYSCALL.INOTIFY_RM_WATCH**
- **SYSCALL.MIGRATE_PAGES**
- **SYSCALL.OPENAT**
- **SYSCALL.MKDIRAT**
- **SYSCALL.MKNODAT**
- **SYSCALL.FCHOWNAT**
- **SYSCALL.FUTIMESAT**
- **SYSCALL.NEWFSTATAT**
- **SYSCALL.UNLINKAT**
- **SYSCALL.RENAMEAT**
- **SYSCALL.LINKAT**
- **SYSCALL.SYMLINKAT**
- **SYSCALL.READLINKAT**
- **SYSCALL.FCHMODAT**
- **SYSCALL.FACCESSAT**
- **SYSCALL.PSELECT6**
- **SYSCALL.PPOLL**
- **SYSCALL.UNSHARE**
- **SYSCALL.SET_ROBUST_LIST**
- **SYSCALL.GET_ROBUST_LIST**
- **SYSCALL.SPLICE**
- **SYSCALL.TEE**
- **SYSCALL.SYNC_FILE_RANGE**
- **SYSCALL.VMSPLICE**
- **SYSCALL.MOVE_PAGES**
- **SYSCALL.UTIMENSAT**
- **SYSCALL.EPOLL_PWAIT**
- **SYSCALL.SIGNALFD**
- **SYSCALL.TIMERFD_CREATE**
- **SYSCALL.EVENTFD**
- **SYSCALL.FALLOCATE**
- **SYSCALL.TIMERFD_SETTIME**
- **SYSCALL.TIMERFD_GETTIME**
- **SYSCALL.ACCEPT4**
- **SYSCALL.SIGNALFD4**
- **SYSCALL.EVENTFD2**
- **SYSCALL.EPOLL_CREATE1**
- **SYSCALL.DUP3**
- **SYSCALL.PIPE2**
- **SYSCALL.INOTIFY_INIT1**
- **SYSCALL.PREADV**
- **SYSCALL.PWRITEV**
- **SYSCALL.RT_TGSIGQUEUEINFO**
- **SYSCALL.PERF_EVENT_OPEN**
- **SYSCALL.RECVMMSG**
- **SYSCALL.FANOTIFY_INIT**
- **SYSCALL.FANOTIFY_MARK**
- **SYSCALL.PRLIMIT64**
- **SYSCALL.NAME_TO_HANDLE_AT**
- **SYSCALL.OPEN_BY_HANDLE_AT**
- **SYSCALL.CLOCK_ADJTIME**
- **SYSCALL.SYNCFS**
- **SYSCALL.SENDMMSG**
- **SYSCALL.SETNS**
- **SYSCALL.GETCPU**
- **SYSCALL.PROCESS_VM_READV**
- **SYSCALL.PROCESS_VM_WRITEV**
- **SYSCALL.KCMP**
- **SYSCALL.FINIT_MODULE**
- **SYSCALL.SCHED_SETATTR**
- **SYSCALL.SCHED_GETATTR**
- **SYSCALL.RENAMEAT2**
- **SYSCALL.SECCOMP**
- **SYSCALL.GETRANDOM**
- **SYSCALL.MEMFD_CREATE**
- **SYSCALL.KEXEC_FILE_LOAD**
- **SYSCALL.BPF**

*/



namespace triton {
  namespace bindings {
    namespace python {

      void initSyscall64Namespace(PyObject* syscallsDict64) {
        PyDict_Clear(syscallsDict64);

        for (triton::uint32 i = 0; i < triton::os::unix::NB_SYSCALL64; ++i)
          xPyDict_SetItemString(syscallsDict64, triton::os::unix::syscallmap64[i], PyLong_FromUint32(i));
      }

      void initSyscall32Namespace(PyObject* syscallsDict32) {
        PyDict_Clear(syscallsDict32);

        #if defined(__unix__)
        for (triton::uint32 i = 0; i < triton::os::unix::NB_SYSCALL32; ++i)
          xPyDict_SetItemString(syscallsDict32, triton::os::unix::syscallmap32[i], PyLong_FromUint32(i));
        #endif
      }

    }; /* python namespace */
  }; /* bindings namespace */
}; /* triton namespace */

#endif /* __unix__ || __APPLE__ */
